package src.array;

public class no26 {
    //删除有序数组中的重复项，快慢指针
    public static void main(String[] args) {
        int[] arr = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(arr));

    }

    public static int removeDuplicates(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int i = 0;
        for (int j = 0; j < nums.length; ) {
            if (nums[j] != nums[i]) {
                nums[i+1] = nums[j];
                i++;
            }else {
                j++;
            }

        }
        return i + 1;

    }
}
